//
//  WHBaseTableCell.m
//  BinFengExpressOwner
//
//  Created by 邓伟浩 on 2018/10/15.
//  Copyright © 2018年 BinFeng. All rights reserved.
//

#import "WHBaseTableCell.h"

@interface WHBaseTableCell ()

@property (nonatomic, strong) UIView *separatorLine;

@end

@implementation WHBaseTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self setUpBaseUI];
        
    }
    return self;
}

- (void)setUpBaseUI {
    [self.contentView addSubview:({
        _separatorLine = [[UIView alloc] init];
        _separatorLine.backgroundColor = CLineColor;
        _separatorLine;
    })];
    
    [_separatorLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView.mas_left).offset(kRealwidth(15));
        make.right.mas_equalTo(self.contentView.mas_right).offset(-kRealwidth(15));
        make.bottom.mas_equalTo(self.contentView.mas_bottom);
        make.height.mas_equalTo(0.5);
    }];
}

- (void)updateLine:(BOOL)isLastCell {
    [_separatorLine mas_updateConstraints:^(MASConstraintMaker *make) {
        if (isLastCell) {
            make.left.right.bottom.mas_equalTo(self.contentView);
        } else {
            make.left.mas_equalTo(self.contentView.mas_left).offset(kRealwidth(15));
            make.right.mas_equalTo(self.contentView.mas_right).offset(-kRealwidth(15));
            make.bottom.mas_equalTo(self.contentView);
        }
        make.height.mas_equalTo(0.5);
    }];
}

- (void)prepareForReuse {
    [super prepareForReuse];
}

@end
